package com.cskaoyan.controller.wx;


import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.wx.WxSearchIndex;
import com.cskaoyan.service.wx.WxSearchService;
import com.cskaoyan.utils.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("wx")
public class WxSearchController {

    @Autowired
    WxSearchService wxSearchService;

    @RequestMapping("search/index")
    public BaseRespVo searchIndex(){
        Integer userId = IdUtils.getId();
        WxSearchIndex wxSearchIndex = wxSearchService.searchIndex(userId);
        return BaseRespVo.ok(wxSearchIndex);
    }
    @RequestMapping("search/helper")
    public BaseRespVo searchHelper(String keyword){
        List<String> keywordArray = wxSearchService.searchHelper(keyword);
        return BaseRespVo.ok(keywordArray);
    }
    @RequestMapping("search/clearhistory")
    public BaseRespVo searchClearHistory(){
        wxSearchService.searchClearHistory();
        return BaseRespVo.ok();
    }
}
